library(MASS)
library(carData)
library(car)
library(fitdistrplus)
library(goft)
First Mediterranean data:
data_M<- read.csv("MED_2017-21.csv",sep=";",dec=",")
head(data_M)
## Covid date specie euros kgs
## 1 Reference No 02/01/2017 ANE-BOQUERON 830.60 111.69
## 2 Reference No 02/01/2017 PIL-SARDINA 129131.37 54232.49
## 3 Reference No 03/01/2017 ANE-BOQUERON 749.13 77.00
## 4 Reference No 03/01/2017 PIL-SARDINA 81008.61 45355.49
## 5 Reference No 04/01/2017 PIL-SARDINA 42228.58 21619.01
## 6 Reference No 05/01/2017 ANE-BOQUERON 28.98 6.85
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:car':
##
## recode
## The following object is masked from 'package:MASS':
##
## select
## The following object is masked from 'package:nlme':
##
## collapse
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
data_M$euros=data_M$euros/data_M$kgs
e=data_M %>%
group_by(specie) %>%
summarise(Mean = mean(euros, na.rm = TRUE))
e$Mean=round(e$Mean,1);e
## # A tibble: 28 x 2
## specie Mean
## <chr> <dbl>
## 1 ANE-BOQUERON 3.2
## 2 ARA-GAMBA ROJA O RAYADO 37.6
## 3 BFT-ATUN ROJO 9.4
## 4 BLT-MELVA 2
## 5 BOG-BOGA 0.4
## 6 BON-BONITO O BONITO DEL SUR 5
## 7 CET-ACEDIA 7.9
## 8 DPS-GAMBA 12.9
## 9 FOR-BROTOLA DE ROCA 7.4
## 10 FRZ-MELVAS 2.3
## # ... with 18 more rows
e=e[c(21,1,6,7,8,9,10,4,16,20,23,26,12,5,2,24,3),]
l=data_M %>%
group_by(specie) %>%
summarise(Mean = mean(kgs, na.rm = TRUE))
l$Mean=round(l$Mean,1);l
## # A tibble: 28 x 2
## specie Mean
## <chr> <dbl>
## 1 ANE-BOQUERON 7882.
## 2 ARA-GAMBA ROJA O RAYADO 528.
## 3 BFT-ATUN ROJO 1869.
## 4 BLT-MELVA 2897.
## 5 BOG-BOGA 1455.
## 6 BON-BONITO O BONITO DEL SUR 393.
## 7 CET-ACEDIA 5
## 8 DPS-GAMBA 1449.
## 9 FOR-BROTOLA DE ROCA 31.2
## 10 FRZ-MELVAS 4602.
## # ... with 18 more rows
l=l[c(21,1,6,7,8,9,10,4,16,20,23,26,12,5,2,24,3),]
Second Golf of Cádiz data:
data_A<- read.csv("ATL_2017-21.csv",sep=";",dec=",")
head(data_A)
## Covid date specie euros kgs
## 1 Reference No 09/01/2017 PIL-SARDINA 37655.47 15055.34
## 2 Reference No 10/01/2017 PIL-SARDINA 41208.45 29884.03
## 3 Reference No 11/01/2017 ANE-BOQUERON 22767.86 4288.60
## 4 Reference No 11/01/2017 PIL-SARDINA 13636.23 7347.15
## 5 Reference No 12/01/2017 ANE-BOQUERON 51289.61 10756.45
## 6 Reference No 12/01/2017 PIL-SARDINA 2415.19 1624.13
data_A$euros=data_A$euros/data_A$kgs
e=data_A%>%
group_by(specie) %>%
summarise(Mean = mean(euros, na.rm = TRUE))
e$Mean=round(e$Mean,1);e
## # A tibble: 27 x 2
## specie Mean
## <chr> <dbl>
## 1 ANE-BOQUERON 2.6
## 2 ARA-GAMBA ROJA O RAYADO 36.5
## 3 BFT-ATUN ROJO 13.2
## 4 BLT-MELVA 1.8
## 5 BOG-BOGA 0.5
## 6 BON-BONITO O BONITO DEL SUR 3.3
## 7 CET-ACEDIA 9.1
## 8 DPS-GAMBA 9.1
## 9 FOR-BROTOLA DE ROCA 5.6
## 10 FRZ-MELVAS 1.8
## # ... with 17 more rows
e=e[c(20,1,6,7,8,9,10,4,15,19,22,25,12,5,2,23,3),]
l=data_A %>%
group_by(specie) %>%
summarise(Mean = mean(kgs, na.rm = TRUE))
l$Mean=round(l$Mean);l
## # A tibble: 27 x 2
## specie Mean
## <chr> <dbl>
## 1 ANE-BOQUERON 29424
## 2 ARA-GAMBA ROJA O RAYADO 330
## 3 BFT-ATUN ROJO 13644
## 4 BLT-MELVA 87
## 5 BOG-BOGA 1228
## 6 BON-BONITO O BONITO DEL SUR 656
## 7 CET-ACEDIA 649
## 8 DPS-GAMBA 12854
## 9 FOR-BROTOLA DE ROCA 84
## 10 FRZ-MELVAS 110
## # ... with 17 more rows
l=l[c(20,1,6,7,8,9,10,4,15,19,22,25,12,5,2,23,3),]
data1=subset(data_A,data_A$specie=="OCC-PULPO DE ROCA O PULPO ROQUERO")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.500 5.013 5.327 5.605 5.778 11.535
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.16061, p-value = 8.882e-16
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 18.986, p-value < 2.2e-16
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 6.3 542.1 5481.5 7056.6 9601.0 62604.0
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.10729, p-value = 2.83e-07
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -2.2071, p-value = 0.1186
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 75 79
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.19902 -0.06195 -0.01543 0.05736 0.26905
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.67550 0.01067 157.102 < 2e-16 ***
## xauxstate of alarm 1 -0.06707 0.01514 -4.431 1.87e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.008189537)
##
## Null deviance: 1.2774 on 142 degrees of freedom
## Residual deviance: 1.1167 on 141 degrees of freedom
## AIC: 186.65
##
## Number of Fisher Scoring iterations: 3
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.3390 -1.5572 -0.0277 0.5220 1.3358
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.7988 0.1039 84.719 <2e-16 ***
## xauxstate of alarm 1 -0.3246 0.1431 -2.268 0.0248 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7658476)
##
## Null deviance: 259.70 on 149 degrees of freedom
## Residual deviance: 255.75 on 148 degrees of freedom
## AIC: 2884.2
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 111 161
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.29748 -0.09188 -0.01463 0.04200 0.38661
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.63300 0.01341 121.759 < 2e-16 ***
## xauxstate of alarm 2 0.06628 0.01713 3.869 0.00014 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.0172679)
##
## Null deviance: 4.2068 on 247 degrees of freedom
## Residual deviance: 3.9496 on 246 degrees of freedom
## AIC: 509.95
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.4074 -1.1779 0.0938 0.4779 1.3848
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.58540 0.06849 125.357 <2e-16 ***
## xauxstate of alarm 2 0.09665 0.09021 1.071 0.285
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5206495)
##
## Null deviance: 434.60 on 261 degrees of freedom
## Residual deviance: 434.01 on 260 degrees of freedom
## AIC: 5043.6
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 96 103
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.18195 -0.06798 -0.01654 0.04915 0.25710
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.704552 0.009939 171.50 < 2e-16 ***
## xauxafter state of alarm 0.056910 0.014371 3.96 0.000107 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.009482818)
##
## Null deviance: 1.8197 on 183 degrees of freedom
## Residual deviance: 1.6709 on 182 degrees of freedom
## AIC: 298.98
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.0236 -1.7309 -0.9757 0.7842 1.7207
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.1006 0.1124 80.989 <2e-16 ***
## xauxafter state of alarm -1.5372 0.1606 -9.569 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.199524)
##
## Null deviance: 515.85 on 185 degrees of freedom
## Residual deviance: 416.35 on 184 degrees of freedom
## AIC: 3436
##
## Number of Fisher Scoring iterations: 7
data1=subset(data_A,data_A$specie=="ANE-BOQUERON")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.5219 1.4497 2.1756 2.6123 3.3159 11.8728
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.070339, p-value = 0.003156
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 6.6554, p-value = 2.525e-06
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.9 9426.2 25451.1 29424.2 44971.4 105501.2
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.11193, p-value = 1.606e-07
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -9.2321, p-value = 6.661e-11
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 55 63
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.12717 -0.46991 -0.07522 0.23646 0.94600
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.73457 0.07121 10.316 < 2e-16 ***
## xauxstate of alarm 1 0.27623 0.09679 2.854 0.00518 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2535242)
##
## Null deviance: 29.225 on 108 degrees of freedom
## Residual deviance: 27.182 on 107 degrees of freedom
## AIC: 334.02
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.9309 -1.0544 -0.1018 0.4568 1.3451
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.8469 0.1126 87.474 < 2e-16 ***
## xauxstate of alarm 1 0.6538 0.1517 4.309 3.66e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6209221)
##
## Null deviance: 177.05 on 108 degrees of freedom
## Residual deviance: 165.96 on 107 degrees of freedom
## AIC: 2446.5
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 61 79
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.84421 -0.45429 -0.09992 0.32447 0.89586
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.13295 0.06118 18.519 < 2e-16 ***
## xauxstate of alarm 2 -0.37314 0.08246 -4.525 1.37e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2170772)
##
## Null deviance: 32.413 on 128 degrees of freedom
## Residual deviance: 27.938 on 127 degrees of freedom
## AIC: 390.76
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.7964 -0.7754 0.0429 0.4502 1.1324
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.99785 0.09358 106.841 <2e-16 ***
## xauxstate of alarm 2 0.22539 0.12320 1.829 0.0697 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.481615)
##
## Null deviance: 163.13 on 129 degrees of freedom
## Residual deviance: 161.53 on 128 degrees of freedom
## AIC: 2900.7
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 84 89
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.8348 -0.3872 -0.1519 0.2403 0.9615
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.75413 0.04765 15.828 <2e-16 ***
## xauxafter state of alarm -0.19574 0.06759 -2.896 0.0043 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1861451)
##
## Null deviance: 30.127 on 162 degrees of freedom
## Residual deviance: 28.569 on 161 degrees of freedom
## AIC: 375.04
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.79124 -0.54950 -0.02658 0.31195 0.88515
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.17321 0.06234 163.192 < 2e-16 ***
## xauxafter state of alarm 0.53953 0.08870 6.082 8.23e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.322551)
##
## Null deviance: 107.010 on 163 degrees of freedom
## Residual deviance: 95.194 on 162 degrees of freedom
## AIC: 3726.9
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_A,data_A$specie=="BON-BONITO O BONITO DEL SUR")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.3053 2.4311 3.2958 3.2527 3.9832 6.7572
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.061172, p-value = 0.02381
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -8.0428, p-value = 1.292e-08
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.80 69.58 272.33 656.00 796.73 8475.38
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.065285, p-value = 0.01287
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 3.8754, p-value = 0.006138
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 75 62
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.50435 -0.20243 0.00474 0.16339 0.40782
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.12357 0.02656 42.303 <2e-16 ***
## xauxstate of alarm 1 0.08699 0.03980 2.186 0.0307 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.05008495)
##
## Null deviance: 6.7928 on 127 degrees of freedom
## Residual deviance: 6.5528 on 126 degrees of freedom
## AIC: 280.91
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.1984 -1.1869 -0.4652 0.4436 2.1002
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.9143 0.1295 45.669 <2e-16 ***
## xauxstate of alarm 1 0.2714 0.1907 1.423 0.157
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.157198)
##
## Null deviance: 229.75 on 127 degrees of freedom
## Residual deviance: 227.40 on 126 degrees of freedom
## AIC: 1796.8
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 100 127
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.52687 -0.11627 -0.00113 0.13776 0.33368
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.20730 0.02048 58.940 < 2e-16 ***
## xauxstate of alarm 2 0.20034 0.02651 7.558 1.36e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03482435)
##
## Null deviance: 9.5237 on 205 degrees of freedom
## Residual deviance: 7.5632 on 204 degrees of freedom
## AIC: 450.25
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.0081 -1.4172 -0.6590 0.3368 2.7458
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.9391 0.1306 37.824 < 2e-16 ***
## xauxstate of alarm 2 1.0940 0.1750 6.251 2.25e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.602857)
##
## Null deviance: 467.39 on 211 degrees of freedom
## Residual deviance: 409.87 on 210 degrees of freedom
## AIC: 2753
##
## Number of Fisher Scoring iterations: 7
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 85 94
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.46943 -0.16882 0.02088 0.14151 0.34836
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.72776 0.02069 35.18 <2e-16 ***
## xauxafter state of alarm 0.53980 0.02970 18.17 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03680403)
##
## Null deviance: 18.5631 on 166 degrees of freedom
## Residual deviance: 6.4894 on 165 degrees of freedom
## AIC: 262.65
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.0324 -0.7139 -0.1901 0.3958 1.4186
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.11085 0.08003 88.852 <2e-16 ***
## xauxafter state of alarm -1.11147 0.11605 -9.578 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5508195)
##
## Null deviance: 186.00 on 163 degrees of freedom
## Residual deviance: 138.67 on 162 degrees of freedom
## AIC: 2486.8
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_A,data_A$specie=="CET-ACEDIA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.714 7.472 9.291 9.073 10.801 15.066
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.084053, p-value = 0.0001886
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -7.3791, p-value = 1.81e-07
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.42 195.56 389.41 648.87 731.87 6268.88
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.13161, p-value = 2.704e-10
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 3.8312, p-value = 0.006748
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 73 77
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.37900 -0.15258 0.00527 0.11726 0.28862
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.31721 0.02107 109.954 < 2e-16 ***
## xauxstate of alarm 1 -0.13296 0.02930 -4.539 1.2e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03064504)
##
## Null deviance: 5.1642 on 142 degrees of freedom
## Residual deviance: 4.5324 on 141 degrees of freedom
## AIC: 557.5
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.9792 -0.6309 -0.0743 0.4084 1.4014
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.38957 0.08382 64.299 < 2e-16 ***
## xauxstate of alarm 1 0.69620 0.11728 5.936 2.27e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.4777618)
##
## Null deviance: 152.26 on 138 degrees of freedom
## Residual deviance: 135.83 on 137 degrees of freedom
## AIC: 1880.6
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 108 150
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.56538 -0.27847 -0.02376 0.20694 0.48239
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.93296 0.02776 69.634 < 2e-16 ***
## xauxstate of alarm 2 0.27189 0.03576 7.603 6.39e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.07474317)
##
## Null deviance: 22.799 on 243 degrees of freedom
## Residual deviance: 18.570 on 242 degrees of freedom
## AIC: 1077.7
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.4916 -0.9348 -0.3173 0.5293 1.5594
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.07225 0.08995 78.628 < 2e-16 ***
## xauxstate of alarm 2 -0.84482 0.11745 -7.193 8.42e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7928338)
##
## Null deviance: 445.51 on 236 degrees of freedom
## Residual deviance: 403.69 on 235 degrees of freedom
## AIC: 3581.5
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 95 97
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.33670 -0.08931 -0.00536 0.08115 0.29090
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.25477 0.01414 159.505 < 2e-16 ***
## xauxafter state of alarm 0.05812 0.01999 2.907 0.00412 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01738498)
##
## Null deviance: 3.1351 on 173 degrees of freedom
## Residual deviance: 2.9881 on 172 degrees of freedom
## AIC: 584.87
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.08712 -0.54072 0.01104 0.34074 0.93334
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.94993 0.05944 100.106 <2e-16 ***
## xauxafter state of alarm -0.07459 0.08496 -0.878 0.381
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.3391374)
##
## Null deviance: 177.56 on 187 degrees of freedom
## Residual deviance: 177.30 on 186 degrees of freedom
## AIC: 2603.5
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_A,data_A$specie=="DPS-GAMBA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.358 6.723 8.422 9.055 11.116 24.478
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.047178, p-value = 0.1009
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 2.3248, p-value = 0.1002
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.2 4503.8 8136.0 12854.4 13267.8 117255.3
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.14261, p-value = 2.808e-12
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 5.3387, p-value = 0.00016
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 77 72
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.38462 -0.16718 0.00728 0.13680 0.33507
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.92793 0.02195 87.818 < 2e-16 ***
## xauxstate of alarm 1 0.23271 0.03116 7.468 8.59e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03373739)
##
## Null deviance: 6.6556 on 138 degrees of freedom
## Residual deviance: 4.7771 on 137 degrees of freedom
## AIC: 496.04
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.6550 -0.4854 -0.1624 0.1694 1.8609
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.45007 0.09191 102.816 < 2e-16 ***
## xauxstate of alarm 1 -0.54196 0.13141 -4.124 6.42e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5998028)
##
## Null deviance: 106.955 on 138 degrees of freedom
## Residual deviance: 96.914 on 137 degrees of freedom
## AIC: 2822.8
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 111 153
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.60336 -0.24687 -0.04867 0.20622 0.52918
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.15128 0.02792 77.046 <2e-16 ***
## xauxstate of alarm 2 -0.07766 0.03619 -2.146 0.0329 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.07796393)
##
## Null deviance: 19.509 on 246 degrees of freedom
## Residual deviance: 19.148 on 245 degrees of freedom
## AIC: 1099.3
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.7385 -0.6384 -0.0210 0.2668 1.8713
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.15730 0.07504 122.037 <2e-16 ***
## xauxstate of alarm 2 0.21597 0.09786 2.207 0.0282 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5799451)
##
## Null deviance: 262.50 on 249 degrees of freedom
## Residual deviance: 259.72 on 248 degrees of freedom
## AIC: 5149.5
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 98 103
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.4591 -0.1329 -0.0033 0.1499 0.3505
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.42856 0.02035 119.319 <2e-16 ***
## xauxafter state of alarm -0.01799 0.02878 -0.625 0.533
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03935531)
##
## Null deviance: 7.7873 on 189 degrees of freedom
## Residual deviance: 7.7719 on 188 degrees of freedom
## AIC: 850.82
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.7536 -0.9606 -0.2257 0.0806 2.3681
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.83277 0.11588 76.223 <2e-16 ***
## xauxafter state of alarm -0.03238 0.16524 -0.196 0.845
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.248826)
##
## Null deviance: 276.46 on 182 degrees of freedom
## Residual deviance: 276.41 on 181 degrees of freedom
## AIC: 3595
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_A,data_A$specie=="FOR-BROTOLA DE ROCA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.200 4.854 5.818 5.639 6.731 9.750
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.10383, p-value = 7.735e-06
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -18.587, p-value < 2.2e-16
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.45 16.46 56.39 83.86 123.45 425.91
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.070609, p-value = 0.00628
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -2.6982, p-value = 0.0564
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 66 70
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.8795 -0.2747 0.0279 0.2197 0.5186
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.72164 0.04077 42.228 <2e-16 ***
## xauxstate of alarm 1 -0.05099 0.05572 -0.915 0.362
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.09806949)
##
## Null deviance: 14.762 on 126 degrees of freedom
## Residual deviance: 14.680 on 125 degrees of freedom
## AIC: 510.51
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.5875 -0.9810 -0.2797 0.5245 1.3560
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.9038 0.1034 37.748 < 2e-16 ***
## xauxstate of alarm 1 -0.5409 0.1463 -3.698 0.000325 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6738042)
##
## Null deviance: 139.9 on 125 degrees of freedom
## Residual deviance: 130.8 on 124 degrees of freedom
## AIC: 1174.3
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 99 119
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.50772 -0.14592 0.00829 0.13506 0.36526
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.73450 0.02028 85.548 < 2e-16 ***
## xauxstate of alarm 2 0.11841 0.02660 4.451 1.43e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03411966)
##
## Null deviance: 7.8579 on 197 degrees of freedom
## Residual deviance: 7.1866 on 196 degrees of freedom
## AIC: 619.43
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.5987 -1.2034 -0.2790 0.5326 1.6295
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.04443 0.09332 43.338 <2e-16 ***
## xauxstate of alarm 2 0.15691 0.12673 1.238 0.217
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.8012613)
##
## Null deviance: 248.39 on 200 degrees of freedom
## Residual deviance: 247.17 on 199 degrees of freedom
## AIC: 2070.5
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 88 90
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.51366 -0.09974 0.01233 0.10647 0.32859
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.76026 0.01789 98.408 <2e-16 ***
## xauxafter state of alarm -0.05452 0.02499 -2.182 0.0306 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02527666)
##
## Null deviance: 4.5498 on 161 degrees of freedom
## Residual deviance: 4.4294 on 160 degrees of freedom
## AIC: 440.23
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.8900 -0.7730 -0.1170 0.4571 1.0882
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.52967 0.07936 57.081 <2e-16 ***
## xauxafter state of alarm 0.28395 0.11257 2.523 0.0126 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5226786)
##
## Null deviance: 159.70 on 164 degrees of freedom
## Residual deviance: 156.38 on 163 degrees of freedom
## AIC: 1875.8
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_A,data_A$specie=="FRZ-MELVAS")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.140 1.353 1.672 1.786 2.181 4.000
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.058956, p-value = 0.4203
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -3.1885, p-value = 0.02416
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.20 5.00 15.76 109.96 46.45 8127.56
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.76146, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 47.1, p-value < 2.2e-16
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 33 6
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.58971 -0.09963 -0.01174 0.12697 0.41650
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.52380 0.03986 13.140 1.16e-14 ***
## xauxstate of alarm 1 -0.05020 0.09628 -0.521 0.606
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.04608106)
##
## Null deviance: 1.6651 on 34 degrees of freedom
## Residual deviance: 1.6527 on 33 degrees of freedom
## AIC: 33.159
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.4622 -1.5110 -0.9486 0.4156 2.9786
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.4051 0.2702 16.302 <2e-16 ***
## xauxstate of alarm 1 -1.7322 0.7351 -2.356 0.0242 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.336662)
##
## Null deviance: 79.287 on 36 degrees of freedom
## Residual deviance: 70.691 on 35 degrees of freedom
## AIC: 383.82
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 27 31
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.84798 -0.14365 -0.02223 0.12282 0.56529
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.61718 0.05488 11.247 4.71e-15 ***
## xauxstate of alarm 2 -0.09382 0.07761 -1.209 0.233
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.0752833)
##
## Null deviance: 3.824 on 49 degrees of freedom
## Residual deviance: 3.714 on 48 degrees of freedom
## AIC: 71.83
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1040 -1.4227 -0.9605 -0.1901 3.2759
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.2897 0.3141 7.290 1.7e-09 ***
## xauxstate of alarm 2 0.6832 0.4286 1.594 0.117
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.466083)
##
## Null deviance: 101.241 on 53 degrees of freedom
## Residual deviance: 95.192 on 52 degrees of freedom
## AIC: 396.39
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 52 54
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.96473 -0.28649 -0.04483 0.23217 0.67922
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.36050 0.05035 7.160 1.85e-10 ***
## xauxafter state of alarm 0.27679 0.07083 3.908 0.000177 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.119149)
##
## Null deviance: 13.841 on 94 degrees of freedom
## Residual deviance: 12.029 on 93 degrees of freedom
## AIC: 164.32
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.9346 -1.4236 -0.7563 -0.0906 3.3765
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.6916 0.2167 17.037 <2e-16 ***
## xauxafter state of alarm 0.2145 0.3094 0.693 0.49
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.488435)
##
## Null deviance: 199.35 on 103 degrees of freedom
## Residual deviance: 198.15 on 102 degrees of freedom
## AIC: 990.33
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_A,data_A$specie=="LTA-BACORETA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.5028 1.9003 2.4780 2.5790 3.0463 6.5008
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.04154, p-value = 0.4512
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -0.7655, p-value = 0.5883
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.550 8.412 35.645 97.825 117.360 1265.020
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.16334, p-value = 2.415e-10
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 6.9045, p-value = 1.049e-06
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 64 49
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.70107 -0.17661 -0.03767 0.14335 0.53732
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.02460 0.03108 32.97 <2e-16 ***
## xauxstate of alarm 1 -0.11354 0.04810 -2.36 0.0202 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.05795822)
##
## Null deviance: 6.2585 on 102 degrees of freedom
## Residual deviance: 5.9377 on 101 degrees of freedom
## AIC: 200.76
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.6834 -1.5327 -0.3941 0.5068 2.0814
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.3030 0.1358 31.696 <2e-16 ***
## xauxstate of alarm 1 0.3641 0.2061 1.767 0.0802 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.105823)
##
## Null deviance: 187.50 on 105 degrees of freedom
## Residual deviance: 184.01 on 104 degrees of freedom
## AIC: 1155.7
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 54 63
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.95149 -0.30241 -0.00117 0.17446 0.64276
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.785e-01 4.932e-02 17.814 <2e-16 ***
## xauxstate of alarm 2 -4.638e-05 6.849e-02 -0.001 0.999
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1264668)
##
## Null deviance: 14.421 on 107 degrees of freedom
## Residual deviance: 14.421 on 106 degrees of freedom
## AIC: 272.78
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.205 -1.542 -0.686 0.347 2.470
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.4730 0.1813 19.156 <2e-16 ***
## xauxstate of alarm 2 -0.1470 0.2497 -0.589 0.557
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.709321)
##
## Null deviance: 182.36 on 109 degrees of freedom
## Residual deviance: 181.76 on 108 degrees of freedom
## AIC: 967.12
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 72 87
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.74291 -0.21430 -0.00723 0.17032 0.57490
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.68901 0.03318 20.764 < 2e-16 ***
## xauxafter state of alarm 0.31234 0.04882 6.398 2.1e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.08588568)
##
## Null deviance: 16.843 on 144 degrees of freedom
## Residual deviance: 13.313 on 143 degrees of freedom
## AIC: 301.81
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.5762 -1.2827 -0.4057 0.3879 2.3869
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.6765 0.1197 39.064 < 2e-16 ***
## xauxafter state of alarm -0.7915 0.1800 -4.397 2.11e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.175181)
##
## Null deviance: 225.81 on 146 degrees of freedom
## Residual deviance: 204.29 on 145 degrees of freedom
## AIC: 1571.7
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_A,data_A$specie=="NEP-CIGALA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 6.748 13.950 16.773 18.268 21.018 50.387
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.078144, p-value = 0.001135
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 10.013, p-value = 1.438e-12
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.45 257.78 611.47 763.47 1158.36 3528.61
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.070532, p-value = 0.004535
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -6.6211, p-value = 2.843e-06
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 73 67
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.307910 -0.117928 -0.000581 0.093698 0.284494
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.567204 0.017579 146.035 <2e-16 ***
## xauxstate of alarm 1 -0.003184 0.025455 -0.125 0.901
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02101445)
##
## Null deviance: 2.7300 on 129 degrees of freedom
## Residual deviance: 2.7297 on 128 degrees of freedom
## AIC: 537.49
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.95603 -0.67846 -0.06629 0.46635 1.09301
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.87402 0.07897 87.048 <2e-16 ***
## xauxstate of alarm 1 -0.08653 0.11479 -0.754 0.452
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.4302848)
##
## Null deviance: 127.92 on 130 degrees of freedom
## Residual deviance: 127.67 on 129 degrees of freedom
## AIC: 2057.7
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 102 134
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.61511 -0.24369 -0.01318 0.16850 0.52518
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.93221 0.02681 109.36 < 2e-16 ***
## xauxstate of alarm 2 0.21602 0.03553 6.08 5.23e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.06902046)
##
## Null deviance: 17.995 on 222 degrees of freedom
## Residual deviance: 15.474 on 221 degrees of freedom
## AIC: 1393.6
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.0118 -0.7870 -0.1432 0.3485 1.5700
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.14155 0.07698 79.783 <2e-16 ***
## xauxstate of alarm 2 -0.23852 0.10309 -2.314 0.0216 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5688643)
##
## Null deviance: 208.75 on 216 degrees of freedom
## Residual deviance: 205.69 on 215 degrees of freedom
## AIC: 3045.7
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 92 88
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.3834 -0.1385 -0.0191 0.1197 0.3271
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.7664 0.0184 150.326 < 2e-16 ***
## xauxafter state of alarm 0.1091 0.0258 4.227 3.85e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02878513)
##
## Null deviance: 5.4599 on 172 degrees of freedom
## Residual deviance: 4.9462 on 171 degrees of freedom
## AIC: 854.23
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.1828 -0.5732 -0.0162 0.4175 0.9336
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.91307 0.06375 108.45 <2e-16 ***
## xauxafter state of alarm -0.13715 0.08963 -1.53 0.128
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.3454119)
##
## Null deviance: 116.00 on 171 degrees of freedom
## Residual deviance: 115.19 on 170 degrees of freedom
## AIC: 2683.1
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_A,data_A$specie=="RSE-CABRACHO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.80 16.23 20.01 19.00 22.00 27.30
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.14208, p-value = 4.356e-08
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -12.305, p-value < 2.2e-16
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.300 2.350 6.550 9.243 13.100 47.300
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.048134, p-value = 0.2634
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -0.15861, p-value = 0.9107
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 54 38
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.44191 -0.11317 0.02065 0.11632 0.25592
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.94510 0.02440 120.700 < 2e-16 ***
## xauxstate of alarm 1 -0.20279 0.03858 -5.256 1.12e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.030364)
##
## Null deviance: 3.5404 on 84 degrees of freedom
## Residual deviance: 2.7140 on 83 degrees of freedom
## AIC: 439.08
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.0311 -0.8710 -0.2080 0.4706 1.3760
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.9638 0.1118 17.558 <2e-16 ***
## xauxstate of alarm 1 -0.2943 0.1729 -1.702 0.0924 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6254469)
##
## Null deviance: 75.439 on 85 degrees of freedom
## Residual deviance: 73.661 on 84 degrees of freedom
## AIC: 491.68
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 74 89
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.39509 -0.07968 0.03417 0.09419 0.29282
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.95876 0.01822 162.382 <2e-16 ***
## xauxstate of alarm 2 0.04732 0.02450 1.932 0.0553 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02224438)
##
## Null deviance: 3.6419 on 149 degrees of freedom
## Residual deviance: 3.5591 on 148 degrees of freedom
## AIC: 763.03
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.7334 -1.0130 -0.2200 0.4448 1.3839
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.7492 0.1006 17.388 <2e-16 ***
## xauxstate of alarm 2 0.3069 0.1345 2.281 0.0239 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6780472)
##
## Null deviance: 130.96 on 151 degrees of freedom
## Residual deviance: 127.48 on 150 degrees of freedom
## AIC: 887.88
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 67 74
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.47763 -0.09529 0.02406 0.09649 0.21779
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.09376 0.01678 184.37 < 2e-16 ***
## xauxafter state of alarm -0.07879 0.02470 -3.19 0.00179 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01971062)
##
## Null deviance: 3.0060 on 129 degrees of freedom
## Residual deviance: 2.8059 on 128 degrees of freedom
## AIC: 668.85
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1963 -0.9704 -0.1454 0.4405 1.5065
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.46146 0.09884 24.903 < 2e-16 ***
## xauxafter state of alarm -0.68456 0.14429 -4.744 5.5e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6740892)
##
## Null deviance: 136.10 on 129 degrees of freedom
## Residual deviance: 121.42 on 128 degrees of freedom
## AIC: 820.84
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_A,data_A$specie=="SWO-PEZ ESPADA O EMPERADOR" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.893 5.642 6.411 6.582 7.698 11.400
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.096704, p-value = 0.2117
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -2.4143, p-value = 0.08779
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 22 1012 2792 4060 5738 31324
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.074699, p-value = 0.5147
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -0.73367, p-value = 0.6039
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 10 18
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.4964 -0.1401 0.0154 0.2154 0.2154
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.06615 0.06705 30.815 <2e-16 ***
## xauxstate of alarm 1 -0.19463 0.08450 -2.303 0.0299 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.04495864)
##
## Null deviance: 1.4874 on 26 degrees of freedom
## Residual deviance: 1.2452 on 25 degrees of freedom
## AIC: 103.47
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3571 -1.9396 -0.6478 0.4096 1.6352
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.5248 0.3900 19.295 4.04e-16 ***
## xauxstate of alarm 1 -0.5121 0.4823 -1.062 0.299
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.368741)
##
## Null deviance: 57.727 on 25 degrees of freedom
## Residual deviance: 56.116 on 24 degrees of freedom
## AIC: 426.08
##
## Number of Fisher Scoring iterations: 8
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 23 34
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.30183 -0.13773 0.01005 0.10668 0.30157
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.92725 0.03209 60.054 <2e-16 ***
## xauxstate of alarm 2 -0.07762 0.04256 -1.824 0.0743 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02265726)
##
## Null deviance: 1.1840 on 50 degrees of freedom
## Residual deviance: 1.1084 on 49 degrees of freedom
## AIC: 146.61
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.7738 -1.0328 -0.1919 0.4749 1.4288
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.6431 0.1786 48.397 < 2e-16 ***
## xauxstate of alarm 2 -0.7129 0.2357 -3.024 0.00387 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.733548)
##
## Null deviance: 76.690 on 53 degrees of freedom
## Residual deviance: 69.884 on 52 degrees of freedom
## AIC: 1003.7
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 14 14
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.22823 -0.04157 -0.01348 0.05291 0.18024
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.77232 0.02887 61.394 <2e-16 ***
## xauxafter state of alarm -0.01578 0.04083 -0.387 0.702
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.0108338)
##
## Null deviance: 0.26692 on 25 degrees of freedom
## Residual deviance: 0.26530 on 24 degrees of freedom
## AIC: 52.105
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.17530 -0.20725 -0.03169 0.20002 0.72656
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.4755 0.1250 67.814 <2e-16 ***
## xauxafter state of alarm -0.3882 0.1767 -2.196 0.0389 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1874422)
##
## Null deviance: 6.5388 on 23 degrees of freedom
## Residual deviance: 5.6403 on 22 degrees of freedom
## AIC: 432.16
##
## Number of Fisher Scoring iterations: 4
data1=subset(data_A,data_A$specie=="HMY-JURELA O JUREL DORADO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.1024 2.6221 3.3410 3.3917 4.0331 15.5000
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.08412, p-value = 0.001643
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -0.66654, p-value = 0.6374
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.10 10.29 35.58 84.20 91.48 5702.51
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.52547, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 59.199, p-value < 2.2e-16
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 66 69
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.53983 -0.13686 -0.01217 0.14379 0.40983
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.17178 0.02556 45.844 < 2e-16 ***
## xauxstate of alarm 1 0.12135 0.03461 3.506 0.000642 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03593246)
##
## Null deviance: 4.9413 on 120 degrees of freedom
## Residual deviance: 4.5015 on 119 degrees of freedom
## AIC: 246.96
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.7928 -1.0893 -0.1753 0.4516 1.6979
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.4768 0.1112 40.277 <2e-16 ***
## xauxstate of alarm 1 -0.2291 0.1554 -1.474 0.143
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7783275)
##
## Null deviance: 172.76 on 128 degrees of freedom
## Residual deviance: 171.07 on 127 degrees of freedom
## AIC: 1389.5
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 65 103
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.57977 -0.31260 -0.00686 0.24254 0.87433
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.10589 0.05240 21.103 <2e-16 ***
## xauxstate of alarm 2 0.01820 0.06688 0.272 0.786
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1675195)
##
## Null deviance: 33.204 on 157 degrees of freedom
## Residual deviance: 33.192 on 156 degrees of freedom
## AIC: 533.18
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.1584 -1.4052 -0.6743 0.2321 4.3443
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.3391 0.2000 16.70 <2e-16 ***
## xauxstate of alarm 2 0.3435 0.2544 1.35 0.179
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.519852)
##
## Null deviance: 305.63 on 164 degrees of freedom
## Residual deviance: 301.18 on 163 degrees of freedom
## AIC: 1491
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 92 88
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.47851 -0.13881 0.00736 0.12772 0.42958
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.07387 0.02258 47.565 < 2e-16 ***
## xauxafter state of alarm 0.23016 0.03100 7.425 6.06e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03924782)
##
## Null deviance: 8.7445 on 163 degrees of freedom
## Residual deviance: 6.5954 on 162 degrees of freedom
## AIC: 331.18
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.9848 -0.8135 -0.2063 0.4988 1.4232
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.71140 0.08751 42.413 < 2e-16 ***
## xauxafter state of alarm 0.87127 0.12304 7.081 3.61e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6508826)
##
## Null deviance: 214.98 on 171 degrees of freedom
## Residual deviance: 183.42 on 170 degrees of freedom
## AIC: 1779.7
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_A,data_A$specie=="BOG-BOGA" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.009987 0.075151 0.260007 0.455654 0.400949 27.650000
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.7789, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 78.691, p-value < 2.2e-16
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.81 30.65 202.98 1228.49 1520.09 10600.00
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.1203, p-value = 0.01158
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 0.53884, p-value = 0.7032
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 34 28
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.6873 -0.7345 -0.1761 0.4731 1.6196
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.3807 0.1285 -10.75 1.62e-15 ***
## xauxstate of alarm 1 -0.4420 0.1896 -2.33 0.0232 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5447963)
##
## Null deviance: 35.754 on 60 degrees of freedom
## Residual deviance: 32.853 on 59 degrees of freedom
## AIC: -79.265
##
## Number of Fisher Scoring iterations: 5
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.1307 -2.1336 -1.4009 -0.0763 3.6650
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.2125 0.3529 17.605 <2e-16 ***
## xauxstate of alarm 1 1.2746 0.5133 2.483 0.0162 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 3.611438)
##
## Null deviance: 209.36 on 54 degrees of freedom
## Residual deviance: 188.00 on 53 degrees of freedom
## AIC: 817.84
##
## Number of Fisher Scoring iterations: 10
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 24 42
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.21824 -0.92223 0.03151 0.38808 0.87711
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.2808 0.1342 -9.541 1.45e-13 ***
## xauxstate of alarm 2 0.1440 0.1637 0.880 0.383
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.3604249)
##
## Null deviance: 29.960 on 60 degrees of freedom
## Residual deviance: 29.685 on 59 degrees of freedom
## AIC: -34.045
##
## Number of Fisher Scoring iterations: 5
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.6401 -1.7368 -0.8162 0.1626 2.5795
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.62258 0.29396 22.53 <2e-16 ***
## xauxstate of alarm 2 -0.06587 0.36598 -0.18 0.858
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.901133)
##
## Null deviance: 135.81 on 61 degrees of freedom
## Residual deviance: 135.75 on 60 degrees of freedom
## AIC: 931.31
##
## Number of Fisher Scoring iterations: 9
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 17 18
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1852 -0.4472 -0.3848 0.0995 1.8082
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.2540 0.2106 -5.955 1.58e-06 ***
## xauxafter state of alarm -0.9220 0.3076 -2.998 0.00542 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7537919)
##
## Null deviance: 24.03 on 31 degrees of freedom
## Residual deviance: 17.60 on 30 degrees of freedom
## AIC: -44.931
##
## Number of Fisher Scoring iterations: 5
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.8570 -2.2203 -1.2086 0.8709 2.0940
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.3499 0.3106 14.006 1.07e-14 ***
## xauxafter state of alarm 2.4116 0.4536 5.316 9.54e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.639837)
##
## Null deviance: 133.765 on 31 degrees of freedom
## Residual deviance: 94.068 on 30 degrees of freedom
## AIC: 401.63
##
## Number of Fisher Scoring iterations: 12
data1=subset(data_A,data_A$specie=="ARA-GAMBA ROJA O RAYADO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 10.70 29.43 34.36 36.46 42.23 93.58
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.055168, p-value = 0.1137
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 5.4031, p-value = 0.0001331
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.30 33.23 135.70 330.40 409.34 3308.44
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.04059, p-value = 0.4196
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 0.73613, p-value = 0.6027
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 65 52
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.244508 -0.090764 -0.005719 0.082665 0.228938
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.36221 0.01474 228.163 <2e-16 ***
## xauxstate of alarm 1 -0.01663 0.02283 -0.728 0.468
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01368042)
##
## Null deviance: 1.4641 on 107 degrees of freedom
## Residual deviance: 1.4568 on 106 degrees of freedom
## AIC: 570.98
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.2023 -1.0621 -0.3503 0.4594 1.5822
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.8961 0.1169 50.448 <2e-16 ***
## xauxstate of alarm 1 0.4196 0.1751 2.396 0.0183 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.833228)
##
## Null deviance: 176.38 on 109 degrees of freedom
## Residual deviance: 171.55 on 108 degrees of freedom
## AIC: 1560.8
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 71 94
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.43854 -0.11225 -0.01510 0.09624 0.36915
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.67337 0.02119 173.372 < 2e-16 ***
## xauxstate of alarm 2 0.21575 0.02789 7.736 1.51e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.0282821)
##
## Null deviance: 5.8778 on 148 degrees of freedom
## Residual deviance: 4.2070 on 147 degrees of freedom
## AIC: 1025.6
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.9953 -1.4029 -0.5891 0.3730 2.1611
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.2777 0.1434 29.831 <2e-16 ***
## xauxstate of alarm 2 0.3490 0.1880 1.856 0.0654 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.316074)
##
## Null deviance: 260.13 on 152 degrees of freedom
## Residual deviance: 255.70 on 151 degrees of freedom
## AIC: 1674.2
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 84 81
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.293707 -0.099510 -0.007575 0.085213 0.281373
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.42644 0.01534 223.392 < 2e-16 ***
## xauxafter state of alarm 0.15728 0.02148 7.322 1.36e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01764458)
##
## Null deviance: 3.6253 on 152 degrees of freedom
## Residual deviance: 2.6813 on 151 degrees of freedom
## AIC: 892.24
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.1982 -1.3864 -0.4394 0.3199 1.8593
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.7554 0.1220 47.184 <2e-16 ***
## xauxafter state of alarm 0.0851 0.1719 0.495 0.621
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.145631)
##
## Null deviance: 277.58 on 154 degrees of freedom
## Residual deviance: 277.30 on 153 degrees of freedom
## AIC: 2099.3
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_A,data_A$specie=="SAA-ALACHA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0100 0.2000 0.2333 2.2234 0.2500 49.5013
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.61861, p-value = 2.187e-14
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 7.3646, p-value = 1.914e-07
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.00 95.25 700.00 4039.50 6875.00 28292.00
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.18185, p-value = 0.1243
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -0.93081, p-value = 0.5104
Regression models
x=as.factor(data1$Covid)
levels(x)
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
data1=subset(data_A,data_A$specie=="BFT-ATUN ROJO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 7.688 10.222 12.906 13.201 15.551 19.950
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.081369, p-value = 0.281
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -0.38469, p-value = 0.7856
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 47.0 929.2 3715.5 13644.5 14168.8 297300.0
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.29088, p-value = 2.656e-11
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 8.1915, p-value = 6.944e-09
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference state of alarm 1" "Reference state of alarm 2"
## [5] "state of alarm 1" "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 36 39
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.34687 -0.20146 0.01516 0.16914 0.30625
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.73835 0.03241 84.479 < 2e-16 ***
## xauxstate of alarm 1 -0.18231 0.04522 -4.032 0.000139 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03677456)
##
## Null deviance: 3.2597 on 71 degrees of freedom
## Residual deviance: 2.6617 on 70 degrees of freedom
## AIC: 351.51
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.82539 -0.98517 -0.41241 0.00846 2.60123
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.0572 0.2253 40.199 <2e-16 ***
## xauxstate of alarm 1 -0.5272 0.3143 -1.677 0.0979 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.776788)
##
## Null deviance: 84.215 on 71 degrees of freedom
## Residual deviance: 79.248 on 70 degrees of freedom
## AIC: 1416
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 1 19
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))[!is.na(as.numeric(names(influential)))]
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.144927 -0.056179 0.008645 0.051247 0.099014
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.35088 0.07650 30.73 1.17e-15 ***
## xauxstate of alarm 2 0.32745 0.07872 4.16 0.000738 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.005852491)
##
## Null deviance: 0.187965 on 17 degrees of freedom
## Residual deviance: 0.095922 on 16 degrees of freedom
## AIC: 58.544
##
## Number of Fisher Scoring iterations: 3
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))[!is.na(as.numeric(names(influential)))]
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.97198 -1.01958 -0.02782 0.31640 1.07280
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.5338 0.7626 8.568 1.42e-07 ***
## xauxstate of alarm 2 3.2506 0.7835 4.149 0.000672 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5815492)
##
## Null deviance: 20.534 on 18 degrees of freedom
## Residual deviance: 16.005 on 17 degrees of freedom
## AIC: 408.57
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 22 31
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.3315 -0.1777 -0.1046 0.1265 0.4797
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.48572 0.04856 51.189 <2e-16 ***
## xauxafter state of alarm -0.05537 0.07393 -0.749 0.457
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.06838266)
##
## Null deviance: 3.0189 on 50 degrees of freedom
## Residual deviance: 2.9807 on 49 degrees of freedom
## AIC: 254.53
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.918 -1.967 -1.512 -0.129 3.358
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.1158 0.3359 24.162 < 2e-16 ***
## xauxafter state of alarm 1.6237 0.5114 3.175 0.00259 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 3.271883)
##
## Null deviance: 202.88 on 50 degrees of freedom
## Residual deviance: 170.90 on 49 degrees of freedom
## AIC: 964.94
##
## Number of Fisher Scoring iterations: 9
data1=subset(data_A,data_A$specie=="BLT-MELVA" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.3968 1.1664 1.4115 1.8119 2.2550 7.1149
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.13014, p-value = 0.00916
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 5.4697, p-value = 0.0001099
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.02 8.13 27.30 87.22 80.82 1010.81
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.24017, p-value = 2.161e-08
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 5.5626, p-value = 8.378e-05
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 21 8
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.0202 -0.1925 -0.1143 0.1372 0.5583
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.99322 0.07618 13.037 1.19e-12 ***
## xauxstate of alarm 1 -0.55457 0.14962 -3.706 0.00105 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1160789)
##
## Null deviance: 4.5521 on 26 degrees of freedom
## Residual deviance: 3.1029 on 25 degrees of freedom
## AIC: 67.492
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.72332 -1.03617 -0.42145 0.03689 1.84167
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.3433 0.2487 9.422 1.05e-09 ***
## xauxstate of alarm 1 0.2971 0.4885 0.608 0.548
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.237154)
##
## Null deviance: 26.313 on 26 degrees of freedom
## Residual deviance: 25.834 on 25 degrees of freedom
## AIC: 190.49
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 9 11
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.05422 -0.27198 -0.03429 0.21184 0.54955
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.29401 0.13380 2.197 0.0431 *
## xauxstate of alarm 2 0.05848 0.17951 0.326 0.7488
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1432182)
##
## Null deviance: 2.7005 on 17 degrees of freedom
## Residual deviance: 2.6853 on 16 degrees of freedom
## AIC: 32.351
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.82458 -0.75914 0.02235 0.25960 1.45408
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.9402 0.2811 10.459 1.47e-08 ***
## xauxstate of alarm 2 -0.8817 0.3772 -2.338 0.0327 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6322249)
##
## Null deviance: 17.120 on 17 degrees of freedom
## Residual deviance: 13.663 on 16 degrees of freedom
## AIC: 128.91
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 39 64
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.65600 -0.21949 -0.01287 0.09566 0.70467
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.20316 0.03535 5.747 1.12e-07 ***
## xauxafter state of alarm 0.28337 0.05619 5.043 2.22e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.072488)
##
## Null deviance: 8.2514 on 95 degrees of freedom
## Residual deviance: 6.3772 on 94 degrees of freedom
## AIC: 73.35
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.6174 -1.2001 -0.3292 0.2830 2.1121
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.6679 0.1409 33.123 < 2e-16 ***
## xauxafter state of alarm -0.9885 0.2270 -4.355 3.39e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.171705)
##
## Null deviance: 141.56 on 95 degrees of freedom
## Residual deviance: 121.61 on 94 degrees of freedom
## AIC: 1022.1
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_M,data_M$specie=="OCC-PULPO DE ROCA O PULPO ROQUERO")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.973 5.784 6.188 6.318 6.846 10.000
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.060044, p-value = 0.02084
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 3.5197, p-value = 0.01282
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.4 1328.8 4405.4 4124.3 6176.6 13266.7
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.14301, p-value = 1.14e-11
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -11.632, p-value < 2.2e-16
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 73 72
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.12035 -0.04469 -0.00082 0.04019 0.14068
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.781674 0.006449 276.27 <2e-16 ***
## xauxstate of alarm 1 -0.155192 0.009401 -16.51 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.002994371)
##
## Null deviance: 1.21243 on 135 degrees of freedom
## Residual deviance: 0.39968 on 134 degrees of freedom
## AIC: 63.525
##
## Number of Fisher Scoring iterations: 3
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.25766 -0.35934 0.04191 0.31800 0.63146
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.69102 0.04913 176.911 <2e-16 ***
## xauxstate of alarm 1 -0.10890 0.07054 -1.544 0.125
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1665252)
##
## Null deviance: 29.051 on 133 degrees of freedom
## Residual deviance: 28.654 on 132 degrees of freedom
## AIC: 2470.7
##
## Number of Fisher Scoring iterations: 4
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 103 144
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.191353 -0.046391 0.001734 0.049823 0.163427
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.825669 0.007361 248.027 < 2e-16 ***
## xauxstate of alarm 2 0.034397 0.009792 3.513 0.000538 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.005255544)
##
## Null deviance: 1.2417 on 222 degrees of freedom
## Residual deviance: 1.1769 on 221 degrees of freedom
## AIC: 291.32
##
## Number of Fisher Scoring iterations: 3
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.63928 -0.27956 0.04822 0.26808 0.76224
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.490809 0.048875 173.727 <2e-16 ***
## xauxstate of alarm 2 -0.002064 0.063327 -0.033 0.974
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2221507)
##
## Null deviance: 106.99 on 229 degrees of freedom
## Residual deviance: 106.99 on 228 degrees of freedom
## AIC: 4298.6
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 94 92
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.23619 -0.09891 0.01059 0.09190 0.19907
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.92905 0.01280 150.718 <2e-16 ***
## xauxafter state of alarm 0.01597 0.01790 0.892 0.374
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01441592)
##
## Null deviance: 2.6491 on 179 degrees of freedom
## Residual deviance: 2.6376 on 178 degrees of freedom
## AIC: 451.86
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.0557 -0.8306 -0.4666 0.1162 1.7821
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.4231 0.1115 66.553 <2e-16 ***
## xauxafter state of alarm -0.1545 0.1568 -0.985 0.326
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.032558)
##
## Null deviance: 173.09 on 167 degrees of freedom
## Residual deviance: 172.09 on 166 degrees of freedom
## AIC: 2810.5
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_M,data_M$specie=="ANE-BOQUERON")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 2.018 2.950 3.163 4.015 11.010
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.020647, p-value = 0.8103
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = NaN, p-value = NA
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.6 641.8 3680.6 7882.5 11334.5 80598.1
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.072767, p-value = 8.106e-05
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -3.3004, p-value = 0.01961
Regression models
ind=which(data1$euros==0)
if(length(ind)>0){data1=data1[-ind,]}
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 62 46
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.80808 -0.26451 -0.03176 0.25467 0.52399
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.03749 0.04533 22.890 <2e-16 ***
## xauxstate of alarm 1 -0.01716 0.06790 -0.253 0.801
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1150453)
##
## Null deviance: 12.713 on 100 degrees of freedom
## Residual deviance: 12.705 on 99 degrees of freedom
## AIC: 280.68
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.8489 -1.3561 -0.2949 0.4990 1.4516
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.089996 0.129131 70.393 <2e-16 ***
## xauxstate of alarm 1 -0.001717 0.199856 -0.009 0.993
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.000495)
##
## Null deviance: 187.7 on 102 degrees of freedom
## Residual deviance: 187.7 on 101 degrees of freedom
## AIC: 2073.9
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 82 102
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.51438 -0.39923 -0.03821 0.34049 0.86772
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.99579 0.05430 18.340 <2e-16 ***
## xauxstate of alarm 2 0.01278 0.07272 0.176 0.861
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2269999)
##
## Null deviance: 49.123 on 173 degrees of freedom
## Residual deviance: 49.116 on 172 degrees of freedom
## AIC: 587.77
##
## Number of Fisher Scoring iterations: 5
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.8000 -1.2816 -0.3583 0.5098 1.3622
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.7346 0.1056 82.74 < 2e-16 ***
## xauxstate of alarm 2 0.4173 0.1410 2.96 0.00351 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.8468987)
##
## Null deviance: 307.67 on 172 degrees of freedom
## Residual deviance: 300.42 on 171 degrees of freedom
## AIC: 3441.9
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 78 85
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.10381 -0.32699 -0.04062 0.30091 0.63865
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.12480 0.04158 27.052 < 2e-16 ***
## xauxafter state of alarm -0.31951 0.06147 -5.198 6.45e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.143494)
##
## Null deviance: 29.064 on 152 degrees of freedom
## Residual deviance: 25.238 on 151 degrees of freedom
## AIC: 442.9
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.9527 -1.0796 -0.3551 0.5073 1.7364
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.4848 0.1080 87.844 < 2e-16 ***
## xauxafter state of alarm -0.5515 0.1581 -3.489 0.000639 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.9326578)
##
## Null deviance: 293.44 on 149 degrees of freedom
## Residual deviance: 282.36 on 148 degrees of freedom
## AIC: 3056.1
##
## Number of Fisher Scoring iterations: 7
data1=subset(data_M,data_M$specie=="BON-BONITO O BONITO DEL SUR")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.200 4.163 4.990 5.009 5.831 8.620
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.032006, p-value = 0.599
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -5.8208, p-value = 3.856e-05
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.75 16.92 70.55 393.17 319.32 25150.38
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.5023, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 35.017, p-value < 2.2e-16
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 67 68
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.50470 -0.14140 0.01043 0.11425 0.42314
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.60420 0.02663 60.230 <2e-16 ***
## xauxstate of alarm 1 -0.03658 0.03863 -0.947 0.346
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.04540101)
##
## Null deviance: 5.6419 on 121 degrees of freedom
## Residual deviance: 5.6012 on 120 degrees of freedom
## AIC: 358.85
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.0734 -1.7771 -0.4881 0.3370 2.6349
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.39147 0.15996 33.704 <2e-16 ***
## xauxstate of alarm 1 0.04041 0.22622 0.179 0.859
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.637644)
##
## Null deviance: 296.44 on 127 degrees of freedom
## Residual deviance: 296.38 on 126 degrees of freedom
## AIC: 1610.3
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 90 129
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.42161 -0.14268 0.02053 0.12305 0.35919
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.61735 0.01989 81.306 < 2e-16 ***
## xauxstate of alarm 2 0.11309 0.02545 4.443 1.46e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03126017)
##
## Null deviance: 7.2224 on 202 degrees of freedom
## Residual deviance: 6.6107 on 201 degrees of freedom
## AIC: 566.09
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.7716 -1.4316 -0.7901 0.1635 3.1035
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.64643 0.15483 30.010 <2e-16 ***
## xauxstate of alarm 2 -0.03659 0.20202 -0.181 0.856
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.037565)
##
## Null deviance: 392.83 on 205 degrees of freedom
## Residual deviance: 392.77 on 204 degrees of freedom
## AIC: 2296.8
##
## Number of Fisher Scoring iterations: 7
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 82 88
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.58233 -0.15373 0.00493 0.12802 0.44724
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.500675 0.024434 61.417 <2e-16 ***
## xauxafter state of alarm -0.005236 0.034785 -0.151 0.881
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.04597193)
##
## Null deviance: 7.2721 on 151 degrees of freedom
## Residual deviance: 7.2711 on 150 degrees of freedom
## AIC: 424.64
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.967 -1.859 -0.904 0.391 2.588
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.4938 0.1618 33.956 <2e-16 ***
## xauxafter state of alarm 0.1221 0.2317 0.527 0.599
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.146411)
##
## Null deviance: 414.45 on 159 degrees of freedom
## Residual deviance: 413.85 on 158 degrees of freedom
## AIC: 2036.6
##
## Number of Fisher Scoring iterations: 8
data1=subset(data_M,data_M$specie=="CET-ACEDIA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 5.126 7.779 7.867 9.991 35.000
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.14111, p-value = 1.403e-05
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = NaN, p-value = NA
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.130 1.440 2.790 5.040 6.615 46.360
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.13862, p-value = 2.124e-05
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 6.0758, p-value = 1.737e-05
Regression models
ind=which(data1$euros==0)
if(length(ind)>0){data1=data1[-ind,]}
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 51 39
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.12761 -0.16975 0.02368 0.22356 0.63240
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.74033 0.05100 34.127 < 2e-16 ***
## xauxstate of alarm 1 0.28485 0.07357 3.872 0.000229 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1040241)
##
## Null deviance: 12.012 on 76 degrees of freedom
## Residual deviance: 10.452 on 75 degrees of freedom
## AIC: 351.12
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ x, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.719 -1.008 -0.363 0.279 2.564
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.0292 0.1440 14.087 <2e-16 ***
## xstate of alarm 1 -0.1187 0.2188 -0.542 0.589
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.058176)
##
## Null deviance: 78.502 on 89 degrees of freedom
## Residual deviance: 78.193 on 88 degrees of freedom
## AIC: 539.31
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 38 61
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.03463 -0.31421 -0.03373 0.32821 0.81116
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.84755 0.07644 24.170 < 2e-16 ***
## xauxstate of alarm 2 0.44449 0.09545 4.657 1.1e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1928202)
##
## Null deviance: 28.814 on 91 degrees of freedom
## Residual deviance: 24.831 on 90 degrees of freedom
## AIC: 518.29
##
## Number of Fisher Scoring iterations: 5
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.0694 -0.7748 -0.4105 0.4562 1.6553
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.5570 0.1443 10.79 < 2e-16 ***
## xauxstate of alarm 2 -0.5011 0.1843 -2.72 0.00783 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7491782)
##
## Null deviance: 78.038 on 92 degrees of freedom
## Residual deviance: 72.341 on 91 degrees of freedom
## AIC: 418.53
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 32 41
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.7713 -0.1808 0.0815 0.2281 0.7369
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.12924 0.06406 33.238 <2e-16 ***
## xauxafter state of alarm -0.06022 0.09835 -0.612 0.543
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.15594)
##
## Null deviance: 18.118 on 65 degrees of freedom
## Residual deviance: 18.060 on 64 degrees of freedom
## AIC: 370.4
##
## Number of Fisher Scoring iterations: 5
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.9880 -0.8074 -0.4233 0.3192 1.8220
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.0251 0.1389 7.378 2.94e-10 ***
## xauxafter state of alarm -0.2016 0.2122 -0.950 0.345
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7720318)
##
## Null deviance: 51.490 on 69 degrees of freedom
## Residual deviance: 50.801 on 68 degrees of freedom
## AIC: 271.16
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_M,data_M$specie=="DPS-GAMBA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.768 10.716 12.415 12.949 14.816 33.448
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.042294, p-value = 0.2301
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 6.2093, p-value = 1.13e-05
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.9 933.2 1412.7 1449.3 2006.2 3258.3
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.079542, p-value = 0.0009589
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -11.372, p-value = 8.873e-16
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 71 70
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.313220 -0.105727 -0.005387 0.083521 0.310077
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.70665 0.01636 165.48 <2e-16 ***
## xauxstate of alarm 1 -0.37839 0.02359 -16.04 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01819258)
##
## Null deviance: 6.9899 on 130 degrees of freedom
## Residual deviance: 2.3575 on 129 degrees of freedom
## AIC: 510.96
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.74769 -0.23178 -0.05673 0.16063 0.51690
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.84779 0.03474 197.143 < 2e-16 ***
## xauxstate of alarm 1 0.39119 0.05073 7.711 3.28e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.08204376)
##
## Null deviance: 15.416 on 127 degrees of freedom
## Residual deviance: 10.530 on 126 degrees of freedom
## AIC: 1840.7
##
## Number of Fisher Scoring iterations: 4
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 98 135
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.35057 -0.14441 -0.03856 0.07903 0.47156
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.38991 0.01968 121.429 < 2e-16 ***
## xauxstate of alarm 2 0.18831 0.02578 7.305 4.98e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03602471)
##
## Null deviance: 9.2779 on 222 degrees of freedom
## Residual deviance: 7.3780 on 221 degrees of freedom
## AIC: 987.43
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.25303 -0.27642 0.07417 0.24983 0.57416
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.52108 0.03708 202.824 < 2e-16 ***
## xauxstate of alarm 2 -0.20739 0.04839 -4.286 2.75e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1237559)
##
## Null deviance: 40.457 on 217 degrees of freedom
## Residual deviance: 38.160 on 216 degrees of freedom
## AIC: 3439
##
## Number of Fisher Scoring iterations: 4
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 89 90
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.35227 -0.13916 -0.02574 0.15329 0.30656
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.66264 0.01921 138.60 < 2e-16 ***
## xauxafter state of alarm -0.08268 0.02694 -3.07 0.00249 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03137133)
##
## Null deviance: 5.7915 on 172 degrees of freedom
## Residual deviance: 5.4958 on 171 degrees of freedom
## AIC: 802.36
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.73894 -0.24586 -0.02574 0.18830 0.65658
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.99568 0.03471 201.52 <2e-16 ***
## xauxafter state of alarm 0.63519 0.04768 13.32 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.09399784)
##
## Null deviance: 31.373 on 165 degrees of freedom
## Residual deviance: 15.165 on 164 degrees of freedom
## AIC: 2501.6
##
## Number of Fisher Scoring iterations: 4
data1=subset(data_M,data_M$specie=="FOR-BROTOLA DE ROCA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.905 6.318 7.203 7.393 8.277 13.537
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.059268, p-value = 0.03305
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -0.95407, p-value = 0.4999
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.280 6.897 17.460 31.183 39.595 326.690
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.089832, p-value = 0.0001613
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 6.6581, p-value = 2.502e-06
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 66 62
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.45910 -0.17091 0.00604 0.14402 0.34529
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.89911 0.02366 80.263 < 2e-16 ***
## xauxstate of alarm 1 0.14403 0.03451 4.174 5.85e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03471049)
##
## Null deviance: 4.7233 on 116 degrees of freedom
## Residual deviance: 4.1175 on 115 degrees of freedom
## AIC: 403.24
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3838 -0.8398 -0.2796 0.3314 1.3761
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.31266 0.09928 33.368 < 2e-16 ***
## xauxstate of alarm 1 -0.76620 0.14464 -5.297 5.47e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6307705)
##
## Null deviance: 123.60 on 120 degrees of freedom
## Residual deviance: 106.56 on 119 degrees of freedom
## AIC: 959.13
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 98 121
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.33701 -0.13816 -0.02442 0.11082 0.32036
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.97081 0.01655 119.113 <2e-16 ***
## xauxstate of alarm 2 0.03800 0.02264 1.679 0.0948 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02600729)
##
## Null deviance: 5.2628 on 203 degrees of freedom
## Residual deviance: 5.1896 on 202 degrees of freedom
## AIC: 644
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.6628 -1.2295 -0.5782 0.4450 1.9468
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.8528 0.1101 25.91 <2e-16 ***
## xauxstate of alarm 2 0.4086 0.1486 2.75 0.0065 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.115233)
##
## Null deviance: 273.18 on 203 degrees of freedom
## Residual deviance: 264.91 on 202 degrees of freedom
## AIC: 1671.1
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 93 94
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.38714 -0.12665 -0.01183 0.10244 0.30856
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.97311 0.01675 117.774 < 2e-16 ***
## xauxafter state of alarm 0.07214 0.02376 3.036 0.00278 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02385735)
##
## Null deviance: 4.2046 on 168 degrees of freedom
## Residual deviance: 3.9847 on 167 degrees of freedom
## AIC: 528
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3390 -0.9348 -0.1996 0.3198 1.7016
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.48792 0.09042 38.574 <2e-16 ***
## xauxafter state of alarm -0.10718 0.12935 -0.829 0.408
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7358343)
##
## Null deviance: 153.86 on 175 degrees of freedom
## Residual deviance: 153.35 on 174 degrees of freedom
## AIC: 1562.2
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_M,data_M$specie=="FRZ-MELVAS")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.600 1.260 1.667 2.322 3.079 33.397
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.39535, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 35.245, p-value < 2.2e-16
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.00 4.74 135.00 4602.30 4511.52 71910.08
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.21121, p-value = 9.666e-07
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -0.67555, p-value = 0.6329
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 10 8
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.49496 -0.43183 0.00534 0.27505 0.48762
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.8018 0.1139 7.040 4e-06 ***
## xauxstate of alarm 1 0.3057 0.1660 1.842 0.0854 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1167286)
##
## Null deviance: 2.2656 on 16 degrees of freedom
## Residual deviance: 1.8689 on 15 degrees of freedom
## AIC: 47.304
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.0637 -0.9070 -0.2785 0.1228 1.2963
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.2906 0.2644 4.882 0.000199 ***
## xauxstate of alarm 1 0.5275 0.4120 1.280 0.219871
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6988602)
##
## Null deviance: 10.9617 on 16 degrees of freedom
## Residual deviance: 9.7933 on 15 degrees of freedom
## AIC: 87.956
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 26 19
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.07672 -0.50650 -0.08795 0.37995 0.68138
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.79896 0.09067 8.812 4.25e-11 ***
## xauxstate of alarm 2 -0.02197 0.13798 -0.159 0.874
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2055157)
##
## Null deviance: 9.2579 on 43 degrees of freedom
## Residual deviance: 9.2527 on 42 degrees of freedom
## AIC: 124.02
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
## Warning: glm.fit: algorithm did not converge
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
## Warning: glm.fit: algorithm did not converge
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -7.720 -7.321 -6.487 -2.835 2.901
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.8925 0.2906 106.3 <2e-16 ***
## xauxstate of alarm 2 -23.9681 0.4709 -50.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.196341)
##
## Null deviance: 318.35 on 41 degrees of freedom
## Residual deviance: 1427.73 on 40 degrees of freedom
## AIC: 702.28
##
## Number of Fisher Scoring iterations: 25
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 36 52
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.85162 -0.42242 -0.17123 0.03374 1.53919
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.54503 0.07573 7.197 2.27e-10 ***
## xauxafter state of alarm 0.11480 0.11940 0.962 0.339
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2982383)
##
## Null deviance: 19.613 on 86 degrees of freedom
## Residual deviance: 19.336 on 85 degrees of freedom
## AIC: 208.8
##
## Number of Fisher Scoring iterations: 5
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.8334 -2.3107 -0.6497 0.5261 2.0048
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.0650 0.1782 50.872 < 2e-16 ***
## xauxafter state of alarm -1.6913 0.2843 -5.949 6.37e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.619343)
##
## Null deviance: 360.71 on 83 degrees of freedom
## Residual deviance: 313.99 on 82 degrees of freedom
## AIC: 1495.9
##
## Number of Fisher Scoring iterations: 10
data1=subset(data_M,data_M$specie=="LTA-BACORETA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.2349 1.5590 2.5768 2.5806 3.4565 6.9005
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.080799, p-value = 0.01916
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -4.3852, p-value = 0.00193
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.80 12.24 36.05 742.82 174.39 13036.82
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.36571, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 6.958, p-value = 8.652e-07
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 33 35
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.6834 -0.1466 0.0310 0.1779 0.5030
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.21005 0.04789 25.268 < 2e-16 ***
## xauxstate of alarm 1 -0.18772 0.06666 -2.816 0.00657 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.06880033)
##
## Null deviance: 5.2346 on 61 degrees of freedom
## Residual deviance: 4.6887 on 60 degrees of freedom
## AIC: 155.99
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.58209 -1.46039 -0.81393 0.08539 2.83794
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.2045 0.2634 15.963 <2e-16 ***
## xauxstate of alarm 1 0.1158 0.3696 0.313 0.755
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.15071)
##
## Null deviance: 114.91 on 62 degrees of freedom
## Residual deviance: 114.70 on 61 degrees of freedom
## AIC: 662.8
##
## Number of Fisher Scoring iterations: 6
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 68 86
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.27492 -0.58443 0.05088 0.32915 0.70540
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.86420 0.05866 14.731 <2e-16 ***
## xauxstate of alarm 2 0.05617 0.07819 0.718 0.474
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2271393)
##
## Null deviance: 43.710 on 150 degrees of freedom
## Residual deviance: 43.593 on 149 degrees of freedom
## AIC: 481.11
##
## Number of Fisher Scoring iterations: 5
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.0774 -2.3234 -1.5912 -0.5544 5.5484
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.7793 0.3112 21.782 < 2e-16 ***
## xauxstate of alarm 2 -1.7285 0.4179 -4.137 5.97e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 6.296464)
##
## Null deviance: 670.20 on 145 degrees of freedom
## Residual deviance: 568.12 on 144 degrees of freedom
## AIC: 1828
##
## Number of Fisher Scoring iterations: 14
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 56 48
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.54488 -0.52852 0.01512 0.30054 0.94947
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.61815 0.07460 8.286 8.53e-13 ***
## xauxafter state of alarm 0.05456 0.10182 0.536 0.593
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2448801)
##
## Null deviance: 27.068 on 94 degrees of freedom
## Residual deviance: 26.998 on 93 degrees of freedom
## AIC: 256.58
##
## Number of Fisher Scoring iterations: 5
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.3745 -2.1701 -1.4925 -0.1393 3.6145
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.2059 0.2865 18.174 < 2e-16 ***
## xauxafter state of alarm 1.7097 0.3859 4.431 2.49e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 3.61052)
##
## Null deviance: 404.17 on 97 degrees of freedom
## Residual deviance: 343.58 on 96 degrees of freedom
## AIC: 1316.7
##
## Number of Fisher Scoring iterations: 11
data1=subset(data_M,data_M$specie=="NEP-CIGALA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 21.84 32.10 36.85 38.01 41.82 84.20
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.076884, p-value = 0.001681
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 10.133, p-value = 7.786e-13
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.30 51.89 105.90 133.76 194.17 563.56
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.036423, p-value = 0.4047
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -3.3776, p-value = 0.01692
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 69 68
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.23848 -0.09101 -0.01231 0.09145 0.22284
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.47213 0.01554 223.444 < 2e-16 ***
## xauxstate of alarm 1 -0.16271 0.02147 -7.578 7.06e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01448802)
##
## Null deviance: 2.6263 on 125 degrees of freedom
## Residual deviance: 1.7930 on 124 degrees of freedom
## AIC: 679.78
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.73246 -0.67443 -0.08934 0.34292 1.22281
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.21510 0.08027 64.972 < 2e-16 ***
## xauxstate of alarm 1 -0.49081 0.11530 -4.257 3.98e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.4316647)
##
## Null deviance: 94.161 on 129 degrees of freedom
## Residual deviance: 86.455 on 128 degrees of freedom
## AIC: 1543.7
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 98 135
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.4028 -0.1509 -0.0345 0.1218 0.4369
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.62752 0.02060 176.071 < 2e-16 ***
## xauxstate of alarm 2 0.11259 0.02718 4.143 4.95e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.03862639)
##
## Null deviance: 8.5676 on 213 degrees of freedom
## Residual deviance: 7.9085 on 212 degrees of freedom
## AIC: 1481.2
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.5360 -0.8295 -0.1895 0.3631 1.3471
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.50797 0.08212 54.895 <2e-16 ***
## xauxstate of alarm 2 0.04342 0.10710 0.405 0.686
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6001799)
##
## Null deviance: 172.63 on 215 degrees of freedom
## Residual deviance: 172.53 on 214 degrees of freedom
## AIC: 2384.6
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 89 90
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.24662 -0.09473 0.01281 0.08260 0.23725
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.63379 0.01299 279.8 <2e-16 ***
## xauxafter state of alarm 0.01865 0.01865 1.0 0.319
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01433953)
##
## Null deviance: 2.3843 on 164 degrees of freedom
## Residual deviance: 2.3700 on 163 degrees of freedom
## AIC: 974.3
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.1337 -0.6933 -0.1445 0.3300 1.0643
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.70346 0.07248 64.889 <2e-16 ***
## xauxafter state of alarm 0.11923 0.10251 1.163 0.246
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.4360805)
##
## Null deviance: 101.73 on 165 degrees of freedom
## Residual deviance: 101.14 on 164 degrees of freedom
## AIC: 1891.7
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_M,data_M$specie=="RSE-CABRACHO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.279 10.253 12.691 12.571 14.898 26.800
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.05449, p-value = 0.0483
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = -8.2052, p-value = 6.555e-09
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.36 16.56 31.03 58.63 63.69 595.93
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.16662, p-value = 1.554e-15
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 11.298, p-value = 1.359e-15
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 71 70
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.53058 -0.17892 -0.01259 0.16029 0.35482
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.53288 0.02577 98.298 < 2e-16 ***
## xauxstate of alarm 1 -0.10961 0.03616 -3.031 0.00296 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.04182974)
##
## Null deviance: 5.9466 on 127 degrees of freedom
## Residual deviance: 5.5621 on 126 degrees of freedom
## AIC: 597.37
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.6044 -0.6992 -0.1027 0.3422 1.3775
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.59897 0.08325 43.229 <2e-16 ***
## xauxstate of alarm 1 -0.24167 0.11956 -2.021 0.0453 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.4713207)
##
## Null deviance: 80.329 on 131 degrees of freedom
## Residual deviance: 78.413 on 130 degrees of freedom
## AIC: 1165.6
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 105 138
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.7220 -0.1588 0.0124 0.1473 0.4728
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.483112 0.026360 94.200 <2e-16 ***
## xauxstate of alarm 2 -0.006816 0.033955 -0.201 0.841
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.06184125)
##
## Null deviance: 15.113 on 223 degrees of freedom
## Residual deviance: 15.110 on 222 degrees of freedom
## AIC: 1135.7
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.5407 -0.9355 -0.3465 0.3309 1.9228
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.47648 0.09355 37.160 < 2e-16 ***
## xauxstate of alarm 2 0.37952 0.12508 3.034 0.00269 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.8752456)
##
## Null deviance: 223.97 on 226 degrees of freedom
## Residual deviance: 216.07 on 225 degrees of freedom
## AIC: 2132.8
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 96 96
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.60633 -0.15409 0.01408 0.14523 0.36990
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.633568 0.023292 113.070 <2e-16 ***
## xauxafter state of alarm -0.002776 0.032386 -0.086 0.932
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.04556973)
##
## Null deviance: 8.7374 on 173 degrees of freedom
## Residual deviance: 8.7371 on 172 degrees of freedom
## AIC: 887.97
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3993 -0.9183 -0.4366 0.3653 2.0750
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.8355 0.0997 38.470 < 2e-16 ***
## xauxafter state of alarm 0.5983 0.1406 4.255 3.36e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.8946417)
##
## Null deviance: 182.69 on 180 degrees of freedom
## Residual deviance: 166.74 on 179 degrees of freedom
## AIC: 1862.6
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_M,data_M$specie=="SWO-PEZ ESPADA O EMPERADOR" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.565 6.520 6.994 7.213 7.871 11.000
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.11394, p-value = 0.0002643
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 3.9071, p-value = 0.005732
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 23.5 633.1 1898.3 3226.6 4024.4 35299.5
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.083019, p-value = 0.01745
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 4.1034, p-value = 0.003713
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference state of alarm 1" "Reference state of alarm 2"
## [5] "state of alarm 1" "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 26 24
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.178913 -0.079903 0.006131 0.080356 0.188189
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.13299 0.02105 101.326 < 2e-16 ***
## xauxstate of alarm 1 -0.14180 0.02977 -4.763 2.29e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.009748922)
##
## Null deviance: 0.62981 on 43 degrees of freedom
## Residual deviance: 0.40882 on 42 degrees of freedom
## AIC: 106.13
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.4955 -0.8711 -0.3593 0.4480 1.6210
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.9194 0.1773 39.030 <2e-16 ***
## xauxstate of alarm 1 0.3346 0.2564 1.305 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7543237)
##
## Null deviance: 44.585 on 45 degrees of freedom
## Residual deviance: 43.299 on 44 degrees of freedom
## AIC: 748.81
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 39 50
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.31549 -0.13805 0.02454 0.11745 0.27988
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.10572 0.02613 80.576 <2e-16 ***
## xauxstate of alarm 2 -0.03593 0.03478 -1.033 0.304
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02526896)
##
## Null deviance: 2.1952 on 84 degrees of freedom
## Residual deviance: 2.1682 on 83 degrees of freedom
## AIC: 288.09
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.2421 -1.2099 -0.4707 0.4608 1.8194
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.6938 0.1667 40.159 <2e-16 ***
## xauxstate of alarm 2 0.3386 0.2215 1.529 0.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.000175)
##
## Null deviance: 99.642 on 82 degrees of freedom
## Residual deviance: 97.350 on 81 degrees of freedom
## AIC: 1316.1
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 97 108
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.20067 -0.04310 0.01264 0.04741 0.16473
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.897444 0.007579 250.365 <2e-16 ***
## xauxafter state of alarm 0.024952 0.011197 2.228 0.0271 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.005571377)
##
## Null deviance: 1.0481 on 178 degrees of freedom
## Residual deviance: 1.0204 on 177 degrees of freedom
## AIC: 271.57
##
## Number of Fisher Scoring iterations: 3
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.7619 -0.8076 -0.2752 0.3519 1.5695
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.08977 0.08375 96.589 <2e-16 ***
## xauxafter state of alarm 0.11493 0.12134 0.947 0.345
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.7014849)
##
## Null deviance: 171.08 on 190 degrees of freedom
## Residual deviance: 170.45 on 189 degrees of freedom
## AIC: 3494.8
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_M,data_M$specie=="HMY-JURELA O JUREL DORADO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.5003 2.6803 3.7075 4.0152 5.1932 17.1991
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.042033, p-value = 0.7267
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 3.7781, p-value = 0.007551
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.340 3.312 7.350 25.221 20.200 673.120
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.41401, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 17.605, p-value < 2.2e-16
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 25 22
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.14237 -0.24879 0.00317 0.25757 0.64688
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.56483 0.07996 19.570 <2e-16 ***
## xauxstate of alarm 1 -0.09001 0.11562 -0.778 0.44
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1534437)
##
## Null deviance: 8.9850 on 45 degrees of freedom
## Residual deviance: 8.8922 on 44 degrees of freedom
## AIC: 193.53
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.9382 -0.6645 -0.1684 0.3758 1.4702
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.4632 0.1582 9.247 1.39e-11 ***
## xauxstate of alarm 1 0.2766 0.2264 1.222 0.229
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5507682)
##
## Null deviance: 26.688 on 42 degrees of freedom
## Residual deviance: 25.866 on 41 degrees of freedom
## AIC: 222.02
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 43 50
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.79033 -0.26249 -0.04324 0.23553 0.58890
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.38207 0.04932 28.023 <2e-16 ***
## xauxstate of alarm 2 -0.01332 0.06684 -0.199 0.842
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.09972594)
##
## Null deviance: 9.2636 on 89 degrees of freedom
## Residual deviance: 9.2597 on 88 degrees of freedom
## AIC: 296.49
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.0332 -0.9881 -0.4768 0.1854 2.2096
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.0912 0.1680 12.45 <2e-16 ***
## xauxstate of alarm 2 0.3821 0.2275 1.68 0.0966 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.128769)
##
## Null deviance: 85.631 on 87 degrees of freedom
## Residual deviance: 82.500 on 86 degrees of freedom
## AIC: 585.7
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 61 59
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.06377 -0.30958 -0.08618 0.20268 0.70374
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.210671 0.055326 21.882 <2e-16 ***
## xauxafter state of alarm -0.005795 0.077207 -0.075 0.94
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1652933)
##
## Null deviance: 18.657 on 110 degrees of freedom
## Residual deviance: 18.656 on 109 degrees of freedom
## AIC: 375.61
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.5353 -1.4124 -0.6162 0.2110 2.7239
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.23119 0.16414 19.685 <2e-16 ***
## xauxafter state of alarm -0.06659 0.23419 -0.284 0.777
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.562663)
##
## Null deviance: 177.44 on 113 degrees of freedom
## Residual deviance: 177.31 on 112 degrees of freedom
## AIC: 959.73
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_M,data_M$specie=="BOG-BOGA" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.2450 0.2822 0.3962 0.4372 3.6466
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.22435, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = NaN, p-value = NA
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.2 36.2 283.3 1455.3 1308.5 17702.1
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.12241, p-value = 2.313e-07
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 2.8123, p-value = 0.04675
Regression models
ind=which(data1$euros==0)
if(length(ind)>0){data1=data1[-ind,]}
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 66 65
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.4813 -0.4396 -0.1621 0.3408 0.9697
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.80590 0.07486 -10.766 <2e-16 ***
## xauxstate of alarm 1 -0.01952 0.10628 -0.184 0.855
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.3586374)
##
## Null deviance: 68.327 on 126 degrees of freedom
## Residual deviance: 68.315 on 125 degrees of freedom
## AIC: 23.473
##
## Number of Fisher Scoring iterations: 5
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.1972 -1.6434 -0.8815 0.1838 3.7187
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.0759 0.1903 26.673 <2e-16 ***
## xauxstate of alarm 1 0.3398 0.2691 1.263 0.209
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.245211)
##
## Null deviance: 291.66 on 123 degrees of freedom
## Residual deviance: 288.10 on 122 degrees of freedom
## AIC: 1518.6
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 86 120
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1818 -0.1494 -0.1098 0.1030 0.9538
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.17314 0.04416 -26.564 <2e-16 ***
## xauxstate of alarm 2 -0.08722 0.05696 -1.531 0.127
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.14628)
##
## Null deviance: 33.777 on 187 degrees of freedom
## Residual deviance: 33.432 on 186 degrees of freedom
## AIC: -273.82
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.6274 -1.4745 -0.4168 0.5389 1.9318
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.9692 0.1195 49.93 <2e-16 ***
## xauxstate of alarm 2 1.8640 0.1570 11.87 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 1.171779)
##
## Null deviance: 559.33 on 194 degrees of freedom
## Residual deviance: 424.84 on 193 degrees of freedom
## AIC: 3100.1
##
## Number of Fisher Scoring iterations: 7
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 76 70
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.51389 -0.17813 -0.08711 0.08301 1.16149
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.10057 0.06033 -18.242 < 2e-16 ***
## xauxafter state of alarm -0.36761 0.08322 -4.417 2.03e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.236587)
##
## Null deviance: 50.755 on 136 degrees of freedom
## Residual deviance: 46.136 on 135 degrees of freedom
## AIC: -147.29
##
## Number of Fisher Scoring iterations: 5
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.6333 -2.3085 -1.1699 0.3083 2.3518
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.6836 0.1768 37.804 < 2e-16 ***
## xauxafter state of alarm 0.8164 0.2438 3.349 0.00106 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.000424)
##
## Null deviance: 483.38 on 134 degrees of freedom
## Residual deviance: 461.83 on 133 degrees of freedom
## AIC: 2078.9
##
## Number of Fisher Scoring iterations: 9
data1=subset(data_M,data_M$specie=="ARA-GAMBA ROJA O RAYADO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 12.91 31.49 36.26 37.64 41.01 85.65
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.091154, p-value = 0.0002293
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 9.6669, p-value = 8.17e-12
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.52 256.82 410.61 528.39 670.18 3131.05
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.06116, p-value = 0.03366
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -1.3604, p-value = 0.3361
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 69 58
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.48154 -0.11683 -0.02041 0.09077 0.41123
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.56969 0.02144 166.493 < 2e-16 ***
## xauxstate of alarm 1 -0.19226 0.03223 -5.966 2.52e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.0312592)
##
## Null deviance: 4.9109 on 121 degrees of freedom
## Residual deviance: 3.8081 on 120 degrees of freedom
## AIC: 776.33
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.9592 -0.6767 -0.1876 0.4194 1.2255
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.08630 0.08877 68.565 <2e-16 ***
## xauxstate of alarm 1 -0.01945 0.13057 -0.149 0.882
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.5042935)
##
## Null deviance: 92.581 on 118 degrees of freedom
## Residual deviance: 92.570 on 117 degrees of freedom
## AIC: 1682.8
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 76 112
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.60295 -0.16905 -0.05135 0.13961 0.53584
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.69406 0.02714 136.130 <2e-16 ***
## xauxstate of alarm 2 0.03487 0.03537 0.986 0.326
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.05301924)
##
## Null deviance: 9.1333 on 174 degrees of freedom
## Residual deviance: 9.0818 on 173 degrees of freedom
## AIC: 1277.4
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.2551 -0.5234 0.0706 0.3549 1.0003
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.95033 0.06427 92.588 < 2e-16 ***
## xauxstate of alarm 2 -0.30834 0.08359 -3.689 0.000299 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.3056335)
##
## Null deviance: 142.53 on 180 degrees of freedom
## Residual deviance: 138.30 on 179 degrees of freedom
## AIC: 2443.3
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 90 90
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.257685 -0.070497 0.005646 0.068994 0.208254
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.54535 0.01206 294.026 < 2e-16 ***
## xauxafter state of alarm 0.10878 0.01666 6.529 7.71e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01163157)
##
## Null deviance: 2.4632 on 167 degrees of freedom
## Residual deviance: 1.9684 on 166 degrees of freedom
## AIC: 944.45
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.6466 -0.5820 -0.1271 0.3745 1.0320
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.50239 0.06470 100.501 <2e-16 ***
## xauxafter state of alarm 0.05779 0.09150 0.632 0.529
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.3558118)
##
## Null deviance: 68.813 on 169 degrees of freedom
## Residual deviance: 68.671 on 168 degrees of freedom
## AIC: 2497.7
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_M,data_M$specie=="SAA-ALACHA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.05486 0.26206 0.29521 0.42460 0.44265 3.46262
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.27523, p-value < 2.2e-16
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 25.915, p-value < 2.2e-16
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.95 1648.86 5150.10 10582.78 11770.38 190873.60
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.16814, p-value = 5.986e-13
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 9.4068, p-value = 2.899e-11
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 59 43
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.87722 -0.24628 -0.09057 0.10428 0.74847
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.12773 0.04304 -26.204 <2e-16 ***
## xauxstate of alarm 1 0.04894 0.06717 0.729 0.468
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1037207)
##
## Null deviance: 9.0614 on 94 degrees of freedom
## Residual deviance: 9.0062 on 93 degrees of freedom
## AIC: -166.18
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.3444 -1.1730 -0.3655 0.6154 1.5323
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.4552 0.1257 67.265 <2e-16 ***
## xauxstate of alarm 1 -0.1682 0.1923 -0.874 0.384
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.8690168)
##
## Null deviance: 153.42 on 95 degrees of freedom
## Residual deviance: 152.76 on 94 degrees of freedom
## AIC: 1803.9
##
## Number of Fisher Scoring iterations: 7
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 84 110
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.0750 -0.3630 -0.2039 0.2065 1.0258
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.74375 0.05340 -13.928 < 2e-16 ***
## xauxstate of alarm 2 -0.25157 0.07064 -3.561 0.000472 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.2224307)
##
## Null deviance: 37.915 on 181 degrees of freedom
## Residual deviance: 35.067 on 180 degrees of freedom
## AIC: -129.5
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.4713 -1.1401 -0.3101 0.5271 1.6272
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.2202 0.1072 76.688 < 2e-16 ***
## xauxstate of alarm 2 0.6786 0.1405 4.831 2.89e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.8732366)
##
## Null deviance: 315.23 on 181 degrees of freedom
## Residual deviance: 295.93 on 180 degrees of freedom
## AIC: 3497.5
##
## Number of Fisher Scoring iterations: 6
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 86 83
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.55305 -0.08895 -0.05182 0.01503 0.92249
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.21982 0.02591 -47.072 <2e-16 ***
## xauxafter state of alarm -0.06346 0.03621 -1.753 0.0816 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.05372383)
##
## Null deviance: 7.0404 on 163 degrees of freedom
## Residual deviance: 6.8753 on 162 degrees of freedom
## AIC: -465.28
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.4746 -1.0080 -0.3529 0.3430 1.8570
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.0129 0.1122 80.338 < 2e-16 ***
## xauxafter state of alarm 0.8559 0.1576 5.429 2.16e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.9691201)
##
## Null deviance: 232.39 on 155 degrees of freedom
## Residual deviance: 204.76 on 154 degrees of freedom
## AIC: 3266.3
##
## Number of Fisher Scoring iterations: 6
data1=subset(data_M,data_M$specie=="BFT-ATUN ROJO" )
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 6.123 8.526 9.006 9.416 10.106 15.373
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.12966, p-value = 6.147e-07
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 9.9871, p-value = 1.642e-12
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 57.0 663.1 1499.0 1869.1 2670.2 8310.6
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.061161, p-value = 0.07111
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = -3.158, p-value = 0.02555
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 42 30
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.18283 -0.08413 -0.01410 0.07488 0.25586
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.26801 0.01735 130.726 <2e-16 ***
## xauxstate of alarm 1 -0.07106 0.02785 -2.552 0.0131 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.01234095)
##
## Null deviance: 0.86005 on 66 degrees of freedom
## Residual deviance: 0.78014 on 65 degrees of freedom
## AIC: 197.36
##
## Number of Fisher Scoring iterations: 4
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.5157 -1.0607 -0.2301 0.5340 1.4946
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.9474 0.1246 55.751 < 2e-16 ***
## xauxstate of alarm 1 -0.8890 0.1956 -4.544 2.36e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.6366878)
##
## Null deviance: 63.125 on 68 degrees of freedom
## Residual deviance: 51.030 on 67 degrees of freedom
## AIC: 1047.3
##
## Number of Fisher Scoring iterations: 5
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 72 102
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.17930 -0.04547 -0.01187 0.04427 0.19930
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.318479 0.009381 247.15 <2e-16 ***
## xauxstate of alarm 2 -0.162466 0.011903 -13.65 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.005368212)
##
## Null deviance: 1.86091 on 160 degrees of freedom
## Residual deviance: 0.84865 on 159 degrees of freedom
## AIC: 331.72
##
## Number of Fisher Scoring iterations: 3
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1561 -0.7852 -0.1035 0.4970 1.1759
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.43229 0.08323 89.303 <2e-16 ***
## xauxstate of alarm 2 -0.04267 0.10887 -0.392 0.696
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.4779315)
##
## Null deviance: 126.76 on 165 degrees of freedom
## Residual deviance: 126.68 on 164 degrees of freedom
## AIC: 2785.5
##
## Number of Fisher Scoring iterations: 5
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 82 83
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.170133 -0.061647 -0.001852 0.041470 0.172476
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.27469 0.00873 260.555 < 2e-16 ***
## xauxafter state of alarm -0.09131 0.01211 -7.543 4.3e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.005487536)
##
## Null deviance: 1.11685 on 149 degrees of freedom
## Residual deviance: 0.80439 on 148 degrees of freedom
## AIC: 314.93
##
## Number of Fisher Scoring iterations: 3
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.19075 -0.72654 -0.06427 0.37713 1.19940
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.46004 0.07618 97.920 <2e-16 ***
## xauxafter state of alarm 0.16778 0.10774 1.557 0.122
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.4411121)
##
## Null deviance: 100.675 on 151 degrees of freedom
## Residual deviance: 99.607 on 150 degrees of freedom
## AIC: 2583.2
##
## Number of Fisher Scoring iterations: 5
data1=subset(data_M,data_M$specie=="BLT-MELVA")
Is gamma a correct distribution for the response variable PRICE?
summary(data1$euros)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.8725 1.1759 1.5087 1.9980 2.6806 5.2000
a=fitdist(data1$euros, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$euros), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$euros)
## D = 0.17954, p-value = 1.711e-05
## alternative hypothesis: two-sided
gamma_test(data1$euros)
##
## Test of fit for the Gamma distribution
##
## data: data1$euros
## V = 4.0454, p-value = 0.00423
Is gamma a correct distribution for the response variable ABUNDANCE?
summary(data1$kgs)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.90 9.18 113.10 2896.89 2790.00 54174.79
a=fitdist(data1$kgs, distr = "gamma",start=list(shape = 1, rate = 2), lower = -1,method = "mme")
plot(a)
ks.test(na.omit(data1$kgs), "pgamma", a$estimate[1],a$estimate[2])
##
## One-sample Kolmogorov-Smirnov test
##
## data: na.omit(data1$kgs)
## D = 0.17142, p-value = 4.803e-05
## alternative hypothesis: two-sided
gamma_test(data1$kgs)
##
## Test of fit for the Gamma distribution
##
## data: data1$kgs
## V = 1.2951, p-value = 0.3598
Regression models
x=as.factor(data1$Covid)
levels(x)
## [1] "after state of alarm" "Reference after state of alarm"
## [3] "Reference No" "Reference state of alarm 1"
## [5] "Reference state of alarm 2" "state of alarm 1"
## [7] "state of alarm 2"
data0=subset(data1,data1$Covid=="Reference state of alarm 1" | data1$Covid=="state of alarm 1")
boxplot(data0$euros~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data0$kgs~data0$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data0$Covid)
table(x)
## x
## Reference state of alarm 1 state of alarm 1
## 10 1
y=as.numeric(data0$euros)
x=relevel(x, ref = "Reference state of alarm 1")
z=as.numeric(data0$kgs)
Model0<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))[!is.na(as.numeric(names(influential)))]
y=y[-influential]
xaux=x[-influential]
Model0<-glm((y)~xaux,family=Gamma(link=log))
summary(Model0)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.142814 -0.039267 0.009279 0.068721 0.089071
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.42582 0.02993 47.640 4.7e-10 ***
## xauxstate of alarm 1 -0.84465 0.08979 -9.407 3.2e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.007166109)
##
## Null deviance: 0.562693 on 8 degrees of freedom
## Residual deviance: 0.051721 on 7 degrees of freedom
## AIC: 9.0413
##
## Number of Fisher Scoring iterations: 3
Model0<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model0)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))[!is.na(as.numeric(names(influential)))]
z=z[-influential]
xaux=x[-influential]
if(length(z)>0){
Model0<-glm((z)~xaux,family=Gamma(link=log))
summary(Model0)}
data01=subset(data1,data1$Covid=="Reference state of alarm 2" | data1$Covid=="state of alarm 2")
boxplot(data01$euros~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data01$kgs~data01$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data01$Covid)
table(x)
## x
## Reference state of alarm 2 state of alarm 2
## 22 40
y=as.numeric(data01$euros)
x=relevel(x, ref = "Reference state of alarm 2")
z=as.numeric(data01$kgs)
Model01<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model01<-glm((y)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.7686 -0.3941 -0.1351 0.3150 0.6548
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.29684 0.08705 3.410 0.001200 **
## xauxstate of alarm 2 0.44769 0.10707 4.181 0.000101 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1515671)
##
## Null deviance: 11.1388 on 58 degrees of freedom
## Residual deviance: 8.6295 on 57 degrees of freedom
## AIC: 122.77
##
## Number of Fisher Scoring iterations: 4
Model01<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model01)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model01<-glm((z)~xaux,family=Gamma(link=log))
summary(Model01)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.5698 -2.1820 -1.1725 0.0361 3.6434
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.3712 0.3808 19.357 < 2e-16 ***
## xauxstate of alarm 2 -2.8032 0.4785 -5.858 2.33e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 3.190303)
##
## Null deviance: 315.73 on 59 degrees of freedom
## Residual deviance: 211.14 on 58 degrees of freedom
## AIC: 741.71
##
## Number of Fisher Scoring iterations: 10
data02=subset(data1,data1$Covid=="Reference after state of alarm" | data1$Covid=="after state of alarm")
boxplot(data02$euros~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Price")
boxplot(data02$kgs~data02$Covid, col = rgb(0, 0.5, 1, alpha = 0.5),xlab="Covid Category",ylab="Abundance")
x=as.factor(data02$Covid)
table(x)
## x
## after state of alarm Reference after state of alarm
## 45 58
y=as.numeric(data02$euros)
x=relevel(x, ref = "Reference after state of alarm")
z=as.numeric(data02$kgs)
Model02<-glm((y)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
y=y[-influential]
xaux=x[-influential]
Model02<-glm((y)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (y) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.4536 -0.2900 -0.1123 0.1371 0.7177
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.49069 0.04579 10.717 <2e-16 ***
## xauxafter state of alarm -0.10285 0.06734 -1.527 0.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.1048202)
##
## Null deviance: 8.5226 on 92 degrees of freedom
## Residual deviance: 8.2788 on 91 degrees of freedom
## AIC: 120.49
##
## Number of Fisher Scoring iterations: 4
Model02<-glm((z)~x,family=Gamma(link=log))
cooksd <- cooks.distance(Model02)
influential <- cooksd[(cooksd > (3 * mean(cooksd, na.rm = TRUE)))]
influential=as.numeric(names(influential))
z=z[-influential]
xaux=x[-influential]
Model02<-glm((z)~xaux,family=Gamma(link=log))
summary(Model02)
##
## Call:
## glm(formula = (z) ~ xaux, family = Gamma(link = log))
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.5612 -2.7284 -1.6420 0.4866 2.3205
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.3405 0.1985 36.976 < 2e-16 ***
## xauxafter state of alarm 1.1455 0.2986 3.836 0.000227 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 2.088828)
##
## Null deviance: 434.98 on 94 degrees of freedom
## Residual deviance: 404.52 on 93 degrees of freedom
## AIC: 1554
##
## Number of Fisher Scoring iterations: 14